import React, { Component } from 'react';


const GlobalContext=React.createContext()//创建Context对象
class  FilmItem extends Component{
    render(){
        return(
            <GlobalContext.Consumer>
            {
                (val)=>{
                    console.log(val);//可以拿到传过来的value
                    return  <div><span>CSDN碰磕</span></div>
                }
            }
            </GlobalContext.Consumer>
        )
    }
}
class Context extends Component {
    render() {
        return (
            //供应商
            <GlobalContext.Provider value={{
                name:"碰磕",
                age:18
            }}>
            <div>
                Context方案
            </div>
            </GlobalContext.Provider>
        );
    }
}

export default Context;